package com.ailanyin.modules.system.controller;

import com.ailanyin.common.base.result.AjaxResult;
import com.ailanyin.modules.system.service.ISysRegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ailanyin
 * @version 1.0
 * @since 2022/3/7 0007 上午 9:29
 */
@RestController
@RequestMapping("/system/region")
@Api(tags = "省市区管理")
public class SysRegionController {

    @Autowired
    private ISysRegionService sysRegionService;

    @GetMapping("/allProvince")
    @ApiOperation(value = "获取所有省")
    public AjaxResult allProvince() {
        return AjaxResult.success(sysRegionService.getAllProvince());
    }

    @GetMapping("/allCity")
    @ApiOperation(value = "获取某省所有市")
    public AjaxResult allCity(@RequestParam(value = "provinceCode") String provinceCode) {
        return AjaxResult.success(sysRegionService.getAllCityByProvinceCode(provinceCode));
    }

    @GetMapping("/allArea")
    @ApiOperation(value = "获取某市所有区")
    public AjaxResult allArea(@RequestParam(value = "cityCode") String cityCode) {
        return AjaxResult.success(sysRegionService.getAllAreaByCityCode(cityCode));
    }

}
